{extend name="layout" /}
{block name="content"}
<style>
    .layui-form-item label {
        width: 120px;
    }
    .classifyimg{
        margin-bottom: 20px;
        width: 672px !important;
    }
    .classifyimg-item{
        display: inline-block;
        width: 140px;
    }
    .classifyimg img{
        width: 100px;
        display: block;
    }
    .classifyimg .layui-form-radio{
        vertical-align: top;
        display: block;
        margin-bottom: 10px;
    }
    .image_storage_type .item{
        display: none;
    }
</style>
<div class="layui-card" style="padding:10px;">
    <div class="layui-tab" lay-filter="setting">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form seller-alone-form" action="" method="post">

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['zhizhao']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5" style="margin-bottom: 10px">
                            <input type="text" name="data[zhizhao]" value="{$data['zhizhao']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入营业执照" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">如：91420103MA49Q1KC2R</div>
                        <label class="layui-form-label">{$data['beian']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[beian]" value="{$data['beian']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入ICP备案号" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">如：京ICP备19000000号-1</div>
                    </div>



                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['address']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[address]" value="{$data['address']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入地址" class="layui-input">
                        </div>

                        <label class="layui-form-label" style="margin-left: 165px;">{$data['mobile']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[mobile]" value="{$data['mobile']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入联系号码" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['email']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[email]" value="{$data['email']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入邮箱" class="layui-input">
                        </div>

                        <label class="layui-form-label" style="margin-left: 165px;">{$data['qq']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[qq]" value="{$data['qq']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入QQ" class="layui-input">
                        </div>

                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['banquansuoyou']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="data[banquansuoyou]" value="{$data['banquansuoyou']['value']}" lay-verify="title" autocomplete="off" placeholder="版权所有" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-form-item">

<!--                        <label class="layui-form-label">{$data['index_banner']['name']}：</label>-->
<!--                        <div class="layui-input-inline">-->
<!--                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(5)">上传图片</button>-->
<!--                            <div class="layui-upload-list" style="width: 400px;height: 100px;">-->
<!--                                <img style="width: 400px;height: 100px;" id="img_preview5" src="{$data['index_banner']['value']}">-->
<!--                            </div>-->
<!--                            <div class="layui-form-mid layui-word-aux">建议尺寸1920*450</div>-->
<!--                        </div>-->

                        <label class="layui-form-label" style="" >{$data['policy_img']['name']}：</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(6)">上传图片</button>
                            <div class="layui-upload-list" style="width: 75px;height: 100px;">
                                <img style="width: 75px;height: 100px;" id="img_preview6" src="{$data['policy_img']['value']}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">建议尺寸300*400</div>
                        </div>
<!--                        <input type="hidden" id="image_id5" name="data[index_banner]" value="{$data['index_banner']['value']}">-->
                        <input type="hidden" id="image_id6" name="data[policy_img]" value="{$data['policy_img']['value']}">
                    </div>





                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['wechat']['name']}：</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(1)">上传图片</button>
                            <div class="layui-upload-list" style="width: 250px;height: 100px;">
                                <img style="width: 100px;height: 100px;" id="img_preview" src="{$data['wechat']['value']}">
                            </div>
                        </div>


                        <label class="layui-form-label" style="margin-left: 220px;" >{$data['wap_qrcode']['name']}：</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(2)">上传图片</button>
                            <div class="layui-upload-list" style="width: 250px;height: 100px;">
                                <img style="width: 100px;height: 100px;" id="img_preview2" src="{$data['wap_qrcode']['value']}">
                            </div>
                        </div>
                        <input type="hidden" id="image_id" name="data[wechat]" value="{$data['wechat']['value']}">
                        <input type="hidden" id="image_id2" name="data[wap_qrcode]" value="{$data['wap_qrcode']['value']}">
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['gongzhonghao']['name']}：</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(3)">上传图片</button>
                            <div class="layui-upload-list" style="width: 250px;height: 100px;">
                                <img style="width: 100px;height: 100px;" id="img_preview3" src="{$data['gongzhonghao']['value']}">
                            </div>
                        </div>


                        <label class="layui-form-label" style="margin-left: 220px;" >{$data['jinritoutiao']['name']}：</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-filter="goods_img" onclick="upImage(4)">上传图片</button>
                            <div class="layui-upload-list" style="width: 250px;height: 100px;">
                                <img style="width: 100px;height: 100px;" id="img_preview4" src="{$data['jinritoutiao']['value']}">
                            </div>
                        </div>
                        <input type="hidden" id="image_id3" name="data[gongzhonghao]" value="{$data['gongzhonghao']['value']}">
                        <input type="hidden" id="image_id4" name="data[jinritoutiao]" value="{$data['jinritoutiao']['value']}">
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;</label>
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="save" style="height: 37px;padding: 0 27px;font-size: 14px;">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['form'], function() {
        var form = layui.form;

        //保存商品
        form.on('submit(save)', function(data) {
            formData = data.field;
            if (!formData) {
                layer.msg('请先完善数据', {
                    time: 1300
                }); //layer.msg(JSON.stringify(data.field));
                return false;
            }
            JsPost('{:url("Config/index")}',formData,function(e){
                if (e.status === true) {
                    layer.msg('保存成功',{
                        time: 1300
                    },function(){
                        window.location.reload();
                    });
                } else {
                    layer.msg(e.msg, {
                        time: 1300
                    });
                }
            });
            return false;
        });


    });

    var _editor = UE.getEditor("edit_image", {
        initialFrameWidth: 800,
        initialFrameHeight: 300,
    });


    _editor.ready(function() {
        _editor.hide();
        _editor.addListener('beforeInsertImage', function(t, arg) {
            if (arg.length > 1) {
                layer.msg("最多只能选择1张图片，请重新选择");
                return false;
            }else {
                if(picture_num==1){
                    $("#image_id").attr("value",arg[0].src);
                    $("#img_preview").attr("src",arg[0].src);
                }else if(picture_num==2){
                    $("#image_id2").attr("value",arg[0].src);
                    $("#img_preview2").attr("src",arg[0].src);
                }else if(picture_num==3){
                    $("#image_id3").attr("value",arg[0].src);
                    $("#img_preview3").attr("src",arg[0].src);
                }else if(picture_num==4){
                    $("#image_id4").attr("value",arg[0].src);
                    $("#img_preview4").attr("src",arg[0].src);
                }else if(picture_num==5){
                    $("#image_id5").attr("value",arg[0].src);
                    $("#img_preview5").attr("src",arg[0].src);
                }else if(picture_num==6){
                    $("#image_id6").attr("value",arg[0].src);
                    $("#img_preview6").attr("src",arg[0].src);
                }

            }
            return true;
        });
    });

    var picture_num = 1
    //上传dialog
    function upImage(num) {
        picture_num = num
        var myImage = _editor.getDialog("insertimage");
        myImage.open();
    }


</script>
<textarea id="edit_image" style="display: none;"></textarea>

{/block}